//
//  GCMHostSearchHttpRequst.m
//  GeeCityManager
//
//  Created by 聚城科技 on 16/3/16.
//  Copyright © 2016年 聚城科技. All rights reserved.
//

#import "GCMHostSearchHttpRequst.h"

@implementation GCMHostSearchHttpRequst


+ (NSURLSessionDataTask *)postDataWithUserName:(NSString *)username Success:(void (^) (id obj , NSError *))success{

    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"userName"] = username;
    
    return [[CZHAppNetAPIClient sharedClient] POST:ROOMCOURT_URL parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        NSMutableDictionary *noticeListDic = [[NSMutableDictionary alloc]init];
        noticeListDic = [dict objectForKey:@"data"];
//        NSLog(@"++1+  %@",noticeListDic);
        if (success) {
            success(noticeListDic,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];

    
}
+ (NSURLSessionDataTask *)postDataWithcourtId:(NSString *)courtId Success:(void (^) (id obj , NSError *))success{
    
    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"courtId"] = courtId;
    
    return [[CZHAppNetAPIClient sharedClient] POST:ROOMBUILDING_URL parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        //NSLog(@"++1+  %@",dict);
        NSMutableDictionary *noticeListDic = [[NSMutableDictionary alloc]init];
        noticeListDic = [dict objectForKey:@"data"];
        if (success) {
            success(noticeListDic,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];
    
}
+ (NSURLSessionDataTask *)postDataWithcourtId:(NSString *)courtId WithbuildingId:(NSString *)buildingId Success:(void (^) (id obj , NSError *))success{

    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"courtId"] = courtId;
    parameters[@"buildingId"] = buildingId;
    
    return [[CZHAppNetAPIClient sharedClient] POST:ROOMUNIT_URL parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
//        NSLog(@"++1+  %@",dict);
        NSMutableDictionary *noticeListDic = [[NSMutableDictionary alloc]init];
        noticeListDic = [dict objectForKey:@"data"];
        if (success) {
            success(noticeListDic,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];

}
+ (NSURLSessionDataTask *)postDataWithcourtId:(NSString *)courtId WithbuildingId:(NSString *)buildingId WithunitId:(NSString *)unitId Success:(void (^) (id obj , NSError *))success{

    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"courtId"] = courtId;
    parameters[@"buildingId"] = buildingId;
    parameters[@"unitId"] = unitId;
    
    return [[CZHAppNetAPIClient sharedClient] POST:ROOMROOM_URL parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        //NSLog(@"++1+房间  %@",dict);
        NSMutableDictionary *noticeListDic = [[NSMutableDictionary alloc]init];
        noticeListDic = [dict objectForKey:@"data"];
        if (success) {
            success(noticeListDic,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];

}
+ (NSURLSessionDataTask *)postDataWithcourtId:(NSString *)courtId WithbuildingId:(NSString *)buildingId WithunitId:(NSString *)unitId WithunitId:(NSString *)roomId Success:(void (^) (id obj , NSError *))success{

    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"courtId"] = courtId;
    parameters[@"buildingId"] = buildingId;
    parameters[@"unitId"] = unitId;
    parameters[@"roomId"] = roomId;
    
    return [[CZHAppNetAPIClient sharedClient] POST:ROOMDETAIL_URL parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
       // NSLog(@"++1+房间信息  %@",dict);
        if (success) {
            success(dict,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];


}
@end
